package com.hc.controller;

import com.hc.appanimal.AnimalActivity;
import com.hc.common.ActionEvent;
import com.hc.constants.Constants;
import com.hc.model.utils.AnimalModel;

public class AnimalController {
	public static AnimalController instance;

	public static AnimalController getInstance() {
		if (instance == null)
			instance = new AnimalController();
		return instance;
	}
	public void handleViewEvent(ActionEvent e) {
		switch (e.action) {
		case Constants.GET_ANIMAL_BY_CATEGORY:
			AnimalModel.getInstance().handleControllerEvent(e);
			break;
			
		case Constants.GET_ANIMAL_BY_STRING:
			AnimalModel.getInstance().handleControllerEvent(e);
			break;

		default:
			break;
		}
	}

	public void handleModelViewEvent(ActionEvent e) {
		switch (e.action) {
		case Constants.GET_ANIMAL_BY_CATEGORY:
			AnimalActivity senderCategory = (AnimalActivity) e.sender;
			senderCategory.handleControllerViewEvent(e);
			break;
			
		case Constants.GET_ANIMAL_BY_STRING:
			AnimalActivity sender = (AnimalActivity) e.sender;
			sender.handleControllerViewEvent(e);
			break;

		default:
			break;
		}
	}
}
